# -*- coding: utf-8 -*-
"""
颜色配置文件
定义应用中使用的所有颜色常量
"""

# 基础颜色定义 (R, G, B)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GRAY = (128, 128, 128)
LIGHT_GRAY = (211, 211, 211)
DARK_GRAY = (64, 64, 64)

# B站主题色
BILIBILI_PINK = (251, 114, 153)
BILIBILI_BLUE = (0, 174, 236)
BILIBILI_LIGHT_BLUE = (102, 204, 255)

# 功能色彩
SUCCESS_GREEN = (76, 175, 80)
WARNING_ORANGE = (255, 152, 0)
ERROR_RED = (244, 67, 54)
INFO_BLUE = (33, 150, 243)

# 背景色
BACKGROUND_COLOR = WHITE
PANEL_BACKGROUND = (248, 249, 250)
INPUT_BACKGROUND = WHITE
BUTTON_BACKGROUND = BILIBILI_PINK
BUTTON_HOVER_BACKGROUND = (231, 94, 133)
BUTTON_DISABLED_BACKGROUND = LIGHT_GRAY

# 文本色
TEXT_PRIMARY = BLACK
TEXT_SECONDARY = GRAY
TEXT_DISABLED = LIGHT_GRAY
TEXT_SUCCESS = SUCCESS_GREEN
TEXT_WARNING = WARNING_ORANGE
TEXT_ERROR = ERROR_RED
TEXT_INFO = INFO_BLUE

# 边框色
BORDER_COLOR = LIGHT_GRAY
BORDER_FOCUS_COLOR = BILIBILI_BLUE
BORDER_ERROR_COLOR = ERROR_RED

# 输入框颜色
INPUT_BORDER = LIGHT_GRAY
INPUT_BORDER_FOCUS = BILIBILI_BLUE
INPUT_BORDER_ERROR = ERROR_RED
INPUT_TEXT = TEXT_PRIMARY
INPUT_PLACEHOLDER = TEXT_SECONDARY

# 按钮颜色
BUTTON_TEXT = WHITE
BUTTON_TEXT_DISABLED = TEXT_DISABLED

# 日志区域颜色
LOG_BACKGROUND = WHITE
LOG_BORDER = BORDER_COLOR
LOG_TEXT_NORMAL = TEXT_PRIMARY
LOG_TEXT_SUCCESS = TEXT_SUCCESS
LOG_TEXT_WARNING = TEXT_WARNING
LOG_TEXT_ERROR = TEXT_ERROR
LOG_TEXT_INFO = TEXT_INFO

# 进度条颜色
PROGRESS_BACKGROUND = LIGHT_GRAY
PROGRESS_FILL = BILIBILI_BLUE
PROGRESS_TEXT = TEXT_PRIMARY

# 主题配置
THEMES = {
    "default": {
        "background": BACKGROUND_COLOR,
        "panel_bg": PANEL_BACKGROUND,
        "text_primary": TEXT_PRIMARY,
        "text_secondary": TEXT_SECONDARY,
        "accent": BILIBILI_PINK,
        "success": SUCCESS_GREEN,
        "warning": WARNING_ORANGE,
        "error": ERROR_RED,
        "info": INFO_BLUE
    },
    "dark": {
        "background": (32, 32, 32),
        "panel_bg": (48, 48, 48),
        "text_primary": WHITE,
        "text_secondary": LIGHT_GRAY,
        "accent": BILIBILI_PINK,
        "success": SUCCESS_GREEN,
        "warning": WARNING_ORANGE,
        "error": ERROR_RED,
        "info": INFO_BLUE
    }
}

# 当前主题
CURRENT_THEME = "default"

def get_theme_color(color_name):
    """
    获取当前主题的颜色
    
    Args:
        color_name (str): 颜色名称
        
    Returns:
        tuple: RGB颜色值
    """
    return THEMES[CURRENT_THEME].get(color_name, BLACK)

def get_current_theme():
    """
    获取当前主题的所有颜色配置
    
    Returns:
        dict: 当前主题的颜色配置字典
    """
    return THEMES[CURRENT_THEME]

def set_theme(theme_name):
    """
    设置当前主题
    
    Args:
        theme_name (str): 主题名称
    """
    global CURRENT_THEME
    if theme_name in THEMES:
        CURRENT_THEME = theme_name